<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        div{
            width: 80px;
            height: 80px;
            background: red;
            border-radius: 20px;
            position: fixed;
            top: 80%;
            left: 50%;
            margin-left: -50px;
            z-index: 2;
        }
        div div{
            width: 30px;
            height: 30px;
            background: yellow;
            border-radius: 50%;
            position: absolute;
            left: 50%;
            margin-left: -15px;
            animation: move 0.3s ease infinite;
        }
        @keyframes move{
            0%{
                transform:translate(0,-100px)
            }
            100%{
                transform:translate(0,-440px)
            }
        }
        nav{
            width: 100px;
            height: 100px;
            background: purple;
            position: absolute;
        }
    </style>
</head>
<body>
    <nav></nav>
    <div class="asd">
        <div class="asdd"></div>
    </div>
</body>
</html>
<script>
    const nav = document.querySelector('nav')
    const asd = document.querySelector('.asd')
    const asdd = document.querySelector('.asdd')
    let offserX = 0;
    let offserY = 0;
    console.log(nav);
    function oft(e){
        const X = e.clientX - offserX
        const Y = e.clientY - offserY
        asd.style.top = Y + 'px'
        asd.style.left = X + 'px'
        console.log(asdd.offsetTop);
        console.log(nav.offsetBottom);
        console.log(e);
        if(asdd.offsetTop == nav.offsetBotton){
            nav.style.display = 'none'
        }
    }
    asd.addEventListener('mousedown', f => {
        offserX = f.offsetX
        offserY = f.offsetY
        document.addEventListener('mousemove',oft)
    })
    document.addEventListener('mouseup',f => {
        document.removeEventListener('mousemove',oft)
    })
</script>